package com.ambitor.ipro.app.gen;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.ambitor.grass.sql.dao.SuperDao;
import com.ambitor.grass.util.data.IData;
import com.ambitor.grass.util.data.IDataset;

public class TaskGeneratorHelper {

	private static final Logger logger = LoggerFactory
			.getLogger(TaskGeneratorHelper.class);

	@SuppressWarnings("unchecked")
	public static void addTask(SuperDao superDao, IData task) throws Exception {
		// BaseDao baseDao = superDao.getBaseDao();
		// Parameter param = new Parameter();
		// param.add(task.getString("PRO_ID"));
		// param.add(TradeState.UN_EXECUTE);
		// param.add(TradeState.UN_EXECUTE_RETRY);
		// String sql = "delete from tf_p_trade_pro_batch"
		// + " where pro_id = ? and trade_state in(?,?)";
		// baseDao.executeUpdate(sql, param);
		superDao.insert("TF_P_TRADE_PRO_BATCH", task);

	}

	public static void addTask(SuperDao superDao, IDataset taskList)
			throws Exception {
		for (int i = 0; i < taskList.size(); i++) {
			IData task = null;
			try {
				task = taskList.getData(i);
			} catch (Exception e) {
				logger.error("taskList.getData(i)出现异常", e);
			}
			addTask(superDao, task);
		}
	}
}
